% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/latlon_from_anything.R
\name{latlon_from_anything}
\alias{latlon_from_anything}
\title{Get lat/lon flexibly - from file, data.frame, data.table, or lat/lon vectors}
\usage{
latlon_from_anything(
  anything,
  lon_if_used,
  interactiveprompt = TRUE,
  invalid_msg_table = FALSE,
  set_invalid_to_na = TRUE
)
}
\arguments{
\item{anything}{If missing and interactive mode in RStudio, prompts user for file. Otherwise,
this can be a filename (csv or xlsx, with path), or data.frame/ data.table/ matrix,
or vector of longitudes (in which case y must be the latitudes).
File or data.frame/data.table/matrix must have columns called lat and lon, or names that can
be inferred to be that by latlon_infer()}

\item{lon_if_used}{If anything parameter is a vector of longitudes, lon_if_used must be the latitudes. Ignored otherwise.}

\item{interactiveprompt}{If TRUE (default) and in interactive mode not running shiny,
will prompt user for file if "anything" is missing.}

\item{invalid_msg_table}{Set to TRUE to add columns "valid" and "invalid_msg" to output}

\item{set_invalid_to_na}{used by latlon_df_clean()}
}
\value{
A data.frame that has at least columns lon and lat (and others if they were in anything),
and a logical column called "valid"
}
\description{
Try to figure out if user provided latitude / longitude
as vectors, data.frame, file, or interactively pick file.
}
\details{
Also see closely related function \code{\link[=sitepoints_from_any]{sitepoints_from_any()}}.

This function relies on

\code{\link[=read_csv_or_xl]{read_csv_or_xl()}}  and

\code{\link[=latlon_df_clean]{latlon_df_clean()}}
which in turn uses \code{\link[=latlon_infer]{latlon_infer()}} \code{\link[=latlon_as.numeric]{latlon_as.numeric()}} \code{\link[=latlon_is.valid]{latlon_is.valid()}}

A draft function \code{\link[=read_and_clean_points]{read_and_clean_points()}} would a more general way to get points,

but is still work in progress... it is similar to latlon_from_anything()

except it also uses these functions:

\code{\link[=latlon_from_regid]{latlon_from_regid()}},  \code{\link[=latlon_from_programid]{latlon_from_programid()}}

and could eventually use  _from_naics() etc.

Even more generally, FIPS and shapefile inputs could be read through a
single wrapper function at some point.
}
\examples{
 latlon_from_anything(testpoints_10)
 latlon_from_anything(testpoints_10$lat, testpoints_10$lon)
 pts = c("33,-100", "32,-101")
 latlon_from_anything(pts)
 pts = data.frame(Longitude = testpoints_10$lon, Latitude = testpoints_10$lat)
 latlon_from_anything(pts)
 pts = data.table(Lat = testpoints_10$lat, Long = testpoints_10$lon)
 latlon_from_anything(pts)
 \dontrun{
 if (interactive()) {
   pts <- latlon_from_anything()
 }}
 \dontrun{
 pts = system.file("testdata/latlon/testpoints_10.xlsx", package = "EJAM")
 latlon_from_anything(pts)
 }
  

}
\seealso{
\code{\link[=sitepoints_from_any]{sitepoints_from_any()}} which is like this but also adds ejam_uniq_id column,
and see \code{\link[=read_csv_or_xl]{read_csv_or_xl()}} and \code{\link[=latlon_df_clean]{latlon_df_clean()}}
}
